<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
		<link rel="stylesheet" href="css/iconfont.css">
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>
		<script src="https://cdn.bootcss.com/angular.js/1.6.3/angular.min.js"></script>
		<script src="js/lib/ecx.js"></script>
	</head>
	 <style>
	 	body{
			font-size:12px;
		}
		table td:nth-child(even) {
			
		}
		table tr:nth-child(2) {
			background-color:#f1f1f1;
		}
		input{
			width:280px;
		}
		#sho{
			width:300px;
			height:50px;
			background:#d9534f;
			opacity:0.8;
			border-radius:8px;
			color:#fff;
			text-align: center;
			font-size:20px;
			position: absolute;
			top:0px;
			left:550px;
			display:none;
		}
		#tt a{
			width:150px;
			height:50px;
			display:block;
			background:rgba(0,0,0,0.8);
			text-align:center;
			line-height:50px;
			float:left;
			margin-left:20px;
			font-size:20px;
			color:#fff;
			visibility:
		}
	 </style>
	<body ng-app="myApp" ng-controller="customersCtrl">
		<div class="">
			<div id="sho"></div>
		    <!--更新用户账户信息-->
			<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover">				
				<tbody id="datatable">
					<tr>
						<td id="tt" colspan="5">
							<a href="#">激活码</a>
						</td>
					</tr>
					<tr id="tr-2">
						<td colspan="5">
						<!--交易时间查询-->激活码生成：
							<input class="form-control" style="width:150px;display:inline-block;margin-left:20px;" type="text" ng-model="size" placeholder="个数" title="每次最多生成1000个" /><!-- <button ng-click="shouji()" class="btn btn-default" style="margin-left:2px;">查询</button> --><span id="error" style="color:red"></span>
							<button class="btn btn-danger" type="button" ng-click="dd()">生成激活码</button>
						</td>
					</tr>
					
					<tr style="font-size:15px;background:rgb(0, 122, 255);color:#fff">
						<td style="width:55px;" class="text-center">序号</td>
						<td class="text-left">创建日期</td>
						<td class="text-left">激活码</td>
						<td class="text-left">状态</td>											
					</tr>
					<tr id="show" ng-repeat="item in items">
						<td class="text-left">{{$index+1}}</td>
						<td class="text-left">{{item.createTime}}</td>
						<td class="text-left">{{item.passkey}}</td>
						<td class="text-left">{{item.status | modify:item.status}}</td>						
					</tr>
					<tr>
						<td colspan="5" ng-show="items.length==0" style="text-align:center;color:#ccc">---------------------------暂无数据--------------------------</td>
					</tr>
					<tr>
						<td colspan="5">								
<a class="btn btn-success" download="激活码.xls" href="#" onclick="return ExcellentExport.excel(this, 'datatable', 'Sheet Name Here');">Excel表格下载</a>
						</td>
					</tr>
				</tbody>
			</table>		
		</div>
		</div>
	</body>
	<script>
		var app = angular.module('myApp', []);
		 /*自定义过滤器   1*/
		app.filter("modify",function(){
			return function(input,param){
				if(param == 0){
					return param = "未激活"
				}
				if(param == 1){
					return param = "已使用"
				}
			}
		})
        app.controller('customersCtrl', function($scope, $http){
        	var brandId = sessionStorage.getItem(key = 3);
        	       	
				$http({
					method:'POST',
					params:{brandId:brandId,size:0},				
					url: window.baseUrl+"paymentchannel/pass/verification/add"					
				}).then(function successCallback(data){
					console.log(data.data)
					$scope.items = data.data.result
				}, function errorCallback(data) {
				     	console.log(data)
				});
				
								
				/*查询*/
				$scope.dd = function(){
					
		        	var brandId = sessionStorage.getItem(key = 3)
		   			var size = $scope.size
					var data = {
						brandId:brandId,size:size
					};
					console.log(data)
						$http({
                        method:'POST',
                        params:data,
                        url: window.baseUrl+"paymentchannel/pass/verification/add"
                    }).then(function successCallback(data){
                        alert("生成激活码成功")
                        $scope.items = data.data.result
                    }, function errorCallback(data) {
                        alert("生成激活码失败")
                        console.log(data)
                    });
				}
        })
	</script>
	<script>
		$(function(){
			var cf = $('.text-center').html();
			console.log(cf)
		})
	</script>
</html>

